package main.java.indi.zyj.sword;

import main.java.indi.zyj.hot100.base.ListNode;

public class DeleteNode {


    public ListNode deleteNode(ListNode head, int val) {

        ListNode top = new ListNode(-1);
        top.next = head;
        ListNode pre = top, p = head;

        while (p != null) {
            if (p.val == val) {
                pre.next = p.next;
                break;
            }
            p = p.next;
            pre = pre.next;
        }

        return top.next;

    }


}
